use super::*;

pub struct ConfigCmd<'a> {
  secret_id: &'a str,
  secret_key: &'a str,
  bucket: &'a str,
  region: &'a str,
}

impl<'a> ConfigCmd<'a> {
  pub fn new(secret_id: &'a str, secret_key: &'a str, bucket: &'a str, region: &'a str) -> Self {
    ConfigCmd {
      secret_id,
      secret_key,
      bucket,
      region,
    }
  }
}

impl<'a> BinaryCommand for ConfigCmd<'a> {
  type Output = ();
  fn exec(&self) -> Self::Output {
    if cfg!(target_os = "windows") {
      panic!("no impl for windows!")
    } else {
      let output = Command::new(COS_BIN)
        .arg("config")
        .arg("-a")
        .arg(self.secret_id)
        .arg("-s")
        .arg(self.secret_key)
        .arg("-b")
        .arg(self.bucket)
        .arg("-r")
        .arg(self.region)
        .output();
      self.process_stdout::<&str>(output, None, None);
    }
  }
}
